/**
 * Definition for a binary tree node.
 * struct TreeNode {
 *     int val;
 *     TreeNode *left;
 *     TreeNode *right;
 *     TreeNode() : val(0), left(nullptr), right(nullptr) {}
 *     TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}
 *     TreeNode(int x, TreeNode *left, TreeNode *right) : val(x), left(left), right(right) {}
 * };
 */
 void mid_read(TreeNode*root,vector<int>&V)
 {
     if(root!=nullptr)
     {
         mid_read(root->left,V);
         V.push_back(root->val);
         mid_read(root->right,V);
     }
 }
class Solution {
public:
    int minDiffInBST(TreeNode* root) {
        vector<int>V;
        mid_read(root,V);
        int min=10e5+1;
        for(int i=0;i<V.size();i++)
        {
            if(i!=0)
            {
                if(V[i]-V[i-1]<min)
                {
                    min=V[i]-V[i-1];
                }
            }
        }
        return min;
    }
};